﻿using System.DirectoryServices;
partial class Program
{
	static void GetLDAPUser() { 
		var filter = "(objectClass=user)";
		var server = "oa.com:389";
		var searchBase = "OU=3.软件所,OU=研究院,OU=生技部,OU=戴德测控技术有限公司,DC=oa,DC=com";
		var username = "deployer@oa.com";
		var password = "opdp2chdmv_ftwmskV";
		var searchRoot = new DirectoryEntry($"LDAP://{server}/{searchBase}", username, password);
		var conn = new DirectorySearcher(searchRoot, filter);
		var n = conn.PropertiesToLoad.Add("sAMAccountName");
		n = conn.PropertiesToLoad.Add("displayName");
		n = conn.PropertiesToLoad.Add("mail");
		n = conn.PropertiesToLoad.Add("distinguishedName");
		n = conn.PropertiesToLoad.Add("objectClass");
		var result = conn.FindAll();
	}
}